Skip to main content

ListOffset

Type

operator

Summary

Find the first or last occurrence of Needle within Haystack Target:An expression which evaluates to a list.

Syntax

the ( first | last ) offset of <Needle> in <Haystack>

Description

Use the offset of to find where a particular sub-list occurs within a list. Haystack is scanned for a sequence of elements that are equal to the elements of Needle, and the position of the start of the sequence found is returned. If neither the "first offset" nor "last offset" are specified, the index of the first matching sub-list found is returned. If no sub-list of Haystack is equal to Needle, the return value is 0.

Parameters

NameTypeDescription

Needle

An expression which evaluates to a list.

Examples

variable tVar as List
variable tOffset as Number
put ["a", "b", "c", "d", "b", "c"]
put the offset of ["b","c"] in tVar into tOffset
-- tOffset contains 2

put the last offset of ["b", "c"] in tVar into tOffset
-- tOffset contains 5
Thank you for your feedback!

Was this page helpful?